The development of the EDVAC computer system of 1948 is often cited as the beginning of the computer era. Since that time, computer systems have evolved into extremely sophisticated devices, and computer systems may be found in many different settings. Computer systems typically include a combination of hardware, such as semiconductors and circuit boards, and software, also known as computer programs.
Fundamentally, computer systems are used for the storage, manipulation, and analysis of data, which may be anything from complicated financial information to simple baking recipes. It is no surprise, then, that the overall value or worth of a computer system depends largely upon how well the computer system stores, manipulates, and analyzes data. One mechanism for managing data is called a database management system (DBMS), which may also be called a database system.
Many different types of databases are known, but the most common is usually called a relational database (RDB), which organizes data in tables that have rows, which represent individual entries or records in the database, and columns, which define what is stored in each entry or record. Columns may also be called fields. Each table has a unique name within the database and each column has a unique name within the particular table. The database also has an index, which is a data structure that informs the database management system of the location of a certain row in a table given an indexed column value, analogous to a book index informing the reader on which page a given word appears.
Databases typically provide keys, and a key is one or more columns in a table that the database uses to sort data. Most database management systems allow more than one key, allowing records to be sorted in different ways. One of the keys is designated the primary key, and must hold a unique value for each row. A key that identifies rows in a different table is called a foreign key. A foreign key (FK) is a field (column) in a database record that points to a field (column) of another database record in another table. Usually a foreign key in one table refers to the primary key of the other table.
Referential integrity is a feature provided by relational database management systems that prevents users or applications from entering inconsistent data between tables. For example, suppose Table B has a foreign key that points to a column in Table A. Referential integrity prevents adding a record to Table B (the child table) that cannot be linked to Table A (the parent table). Thus, the value of the foreign key in the record in table B (the child table) must already exist in the corresponding column in table A (the parent table). Hence, the primary key is often called the parent key and the foreign key the child key in the relationship because a child cannot exist without its parent. In addition, the referential integrity rules might also specify that whenever a record is deleted from Table A (the parent table), any records in Table B (the child table) that are linked to the deleted record are also deleted, which is called a cascading delete. Finally, the referential integrity rules may specify that whenever the value in a linked column is modified in Table A, all records in Table B that are linked to it will also be modified accordingly, which is called a cascading update. Thus, cascading deletes and updates enforce the relationship that a child cannot exist without its parent.
Although referential integrity is a useful technique, it is limited in that it enforces integrity rules in only one direction, i.e., the primary key is the parent and the foreign key is the child in the relationship. Attempting to create bi-directional referential integrity by defining a key in table A as both a primary and a foreign key (and likewise for a key in table B) causes a cyclical constraint, which leads to deadlocks and infinite loops.
Thus, what is needed is a technique for creating bi-directional referential integrity.